package okhttp;

import java.io.IOException;

import okhttp3.Call;
import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;

// https://blog.csdn.net/qq_29152241/article/details/82011539
public class Demo2 {

	public static void main(String[] args) throws IOException {
		OkHttpClient client = new OkHttpClient.Builder().build();
		MediaType mediaType = MediaType.parse("application/json;charset=UTF-8");
		String postStr = "{\"id\":123, \"name\":\"zsl\"}";
		RequestBody requestBody = RequestBody.create(mediaType, postStr);
		Request request = new Request.Builder()
		        .post(requestBody)
		        .url("http://127.0.0.1:8081/test6") // 《springboot2.x》-《com.spring.demo.c9mvc.UserController》
		        .build();
		Call call = client.newCall(request);
		Response response = call.execute();
	}

}
